package com.masblearn;

public class BulletTankColider implements Colider {
    @Override
    public boolean colider(GameObject o1, GameObject o2) {
        if (o1 instanceof Bullet && o2 instanceof Tank) {
            Bullet b = (Bullet) o1;
            Tank t = (Tank) o2;
            if (b.group == t.getGroup()) {
                return true;
            }
            if (b.rect.intersects(t.rectangle)) {
                b.die();
                t.die();
                GameModel.getInstance().add(new Explode(t.getX() + t.TANK_WIDTH / 2 - Explode.Width / 2, t.getY() + t.TANK_HEIGHT / 2 - Explode.Heiht / 2));
            }
            return false;
        } else if (o1 instanceof Tank && o2 instanceof Bullet) {
            colider(o2, o1);
        }
        return true;

    }
}
